<extend name="Base/common_nojhd"/>
<block name="style">
    <link href="__CSS__/user.css" rel="stylesheet" type="text/css" />
</block>
<block name="TITLE"><title>世果365</title></block>
<block name="body">
    <form action="{:U('User/login')}" method="post" id="improve_form">
        <div class="underreview_box">
            <div class="accimpro">用户登录</div>
            <div class="accimpro_box clearFix">
                <div class="phone fl">手机号：</div>
                <input type="text" id="phone" name="phone" class="am-form-field am-radius fl" style="width: 72%;height: 40px;" placeholder="输入你的手机号" value="{:I('phone')}"/>
            </div>
            <div class="accimpro_box clearFix">
                <div class="phone fl">验证码：</div>
                <input type="text" name="code" class="am-form-field am-radius fl" style="width: 32%;height: 40px;" placeholder="输入验证码" value=""/>
                <button type="button" id="sendMessage" disabled="disabled" class="am-btn am-btn-danger" style="width: 40%;height: 40px;text-align: center;font-size: 1.4rem;padding: 0;">
                    获取验证码
                    <span id="limitTime" class="" ></span>
                </button>
            </div>
            <div class="returnbtn">
                <div style="margin: 0 5%;">
                    <button type="submit" id="submit" class="am-btn am-btn-success am-btn-block">下一步</button>
                </div>
            </div>
            <div class="foot">全国领先的网上水果批发平台</div>

        </div>
    </form>
    <div>
        <input type="hidden" id="validTime" value="{$validTime|default=0}">
    </div>
    <script>
        window.onload = function () {
            document.body.style.backgroundColor = "#3EACFF";
        }
        $(function(){
            messageLimit=function(){
                var lastTime=$("#validTime").val();
                var nowTime=new Date().getTime();
                var periodTime=nowTime-lastTime;
                if(periodTime<60*1000){
                    $("#sendMessage").attr('disabled','disabled');
                    $("#limitTime").html("("+(60-parseInt(periodTime/1000))+"s)")
                }else{
                    $("#sendMessage").removeAttr('disabled');
                    $("#limitTime").html('');
                }
            }
            setInterval(messageLimit,500);
            $("#sendMessage").click(function(){
                var phone=$('#phone').val();
                var url ='{:U('User/validate')}';
                var data={phone:phone};
                $.ajax({
                    url:url,
                    type:'POST',
                    async:false,
                    data:data,
                    success:function(respond){
                        if(respond.status==0){
                            $("#validTime").val(new Date().getTime());
                            alert("短信已发送，验证码有效期10分钟");

                        }else{
                            alert("短信发送失败,请确认手机号无误");
                        };
                    }
                })
            });
        })
    </script>
</block>



